<%@ page language="java" pageEncoding="UTF-8"%>
<%@ taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c"%>
<c:set var="path" value="${pageContext.request.contextPath}"/>

<!DOCTYPE html>
<html>
<head>
<base href="${path}/">
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1">
<title>个人博客后台管理</title>
<link rel="stylesheet" href="layui/css/layui.css">
</head>
<body>
	
<div class="layui-fluid">
	<div class="layui-form" lay-filter="uservip"style="margin-top: 10px">
		<input type="hidden" name="user_id" value="${user.user_id}">
  		<div class="layui-form-item">
    		<label class="layui-form-label">用户名</label>
    		<div class="layui-input-block">
      			<input type="text" name="user_name" disabled value="${user.user_name}" lay-verify="required"   autocomplete="off" class="layui-input">
    		</div>
  		</div>
  			<div class="layui-form-item">
    		<label class="layui-form-label">用户密码</label>
    		<div class="layui-input-block">
      			<input type="password" name="user_password" disabled value="${user.user_password}" lay-verify="required"   autocomplete="off" class="layui-input">
    		</div>
  		</div>
  		<div class="layui-form-item">
    		<label class="layui-form-label">用户昵称</label>
    		<div class="layui-input-block">
      			<input type="text" name="user_nickname" disabled value="${user.user_nickname}" placeholder="请输入昵称" autocomplete="off" class="layui-input">
    		</div>
  		</div>
  	   	<div class="layui-form-item">
    		<label class="layui-form-label">用户邮箱</label>
    		<div class="layui-input-block">
      			<input type="text" name="user_email" value="${user.user_email}"  autocomplete="off" class="layui-input">
    		</div>
  		</div>
  		  <div class="layui-form-item">
    		<label class="layui-form-label">生日</label>
    		<div class="layui-input-block">
      			<input type="text" name="user_birthday"  value="${user.user_birthday}" id="biDate" autocomplete="off" class="layui-input">
    		</div>
  		</div>
  		 <div class="layui-form-item">
    		<label class="layui-form-label">年龄</label>
    		<div class="layui-input-block">
      			<input type="text" name="user_age" disabled value="${user.user_age}" disabled autocomplete="off" class="layui-input">
    		</div>
  		</div>
  		 <div class="layui-form-item">
    		<label class="layui-form-label">手机号</label>
    		<div class="layui-input-block">
      			<input type="text" name="user_tel"  value="${user.user_tel}"  autocomplete="off" class="layui-input">
    		</div>
  		</div>
  		  		<div class="layui-form-item">
    		<div class="layui-input-block">
      			<button type="button" class="layui-btn" id="imgbtn">
  					<i class="layui-icon">&#xe67c;</i> 上传用户头像  					
				</button>
				<span id="imgpath" style="margin-left:20px;">
					
					
				</span>
			
				
    		</div>
  		</div>
  		<div class="layui-form-item">
	      	<input type="button" class="layui-btn layui-btn-normal" value="确认修改"lay-submit lay-filter="lay-form-submit" id="lay-form-submit">
	    </div>
  	</div>
  
  	<script src="${path }/layui/layui.js"></script>
	<script>
	layui.use(['form','element','upload','laydate'], function(){
		var form = layui.form;
		var $ = layui.$;
	
		  var element = layui.element;
		  var laydate = layui.laydate;
		  var upload=layui.upload;
			//文件上传
			upload.render({
				elem: '#imgbtn',
				url: '${path}/upload',
				acceptMime:'image/*',
				data:{
					imgType:'users',
					imgId:'${user.user_id}'
				},
				done: function(resp) {
					if(resp.success) {
						var li='';
						$('[name="imgpic"]').val(resp.data.src);
						li+='<input type="hidden" name="user_photo" value="'+resp.data.img_id+'">';
						li+='<input type="hidden" name="imgid" value="'+resp.data.img_id+'">';
						li+='<a target="_blank" href="${path}'+resp.data.src+'">'+resp.data.title+'</a>';
						li+='<img src="${path}'+resp.data.src+'"/>';
						$('#imgpath').html(li);
					}
					layer.msg(resp.msg);
				}			
			});
		  //执行一个laydate实例
		  laydate.render({
		    elem: '#biDate' //指定元素
		  });
		
		
		//监听提交
    	form.on('submit(lay-form-submit)', function(data) {
    		
      		var index = parent.layer.getFrameIndex(window.name); //先得到当前iframe层的索引  
     		//提交ajax成功后，关闭当前弹层并重载表格
      		$.post('${path}/action/user/updateall', data.field, function(json) {
      			if(json.success)
      				layer.msg(json.msg);
      			else
      				layer.alert(json.msg, {icon: 4});
      				parent.layui.table.reload('lay-table'); //重载表格
      	      		parent.layer.close(index); //再执行关闭      				
      			}, 'JSON');
    	});
		
	});	
	
	</script>
</div>

</body>
</html>
